--lua -e"OS='MAC64'" -e"GLOGLVL='INFO'" -lsetpath  ./test/testclientcon.lua
REACTMOD = REACTMOD or 'zsvc.react'

require'zsvc.appbase'
require'zdc.logger'
require'zsvc.accept'
require'zsvc.apphandle'
require'zsvc.notifycon'
require'zsvc.notifymag'
require'zsvc.appcon'
require'zsvc.telnetd'
require'zsvc.clientcon'


LOGGER=zdc.logger.defaultlog

REACT=require(REACTMOD).new()
--REACT=zsvc.react_luaevent.new({logger=LOGGER})
local clis={}
local cbmap={
}

for i=1,20 do
	clis[i]=zsvc.clientcon.new{mon=svc,appaddr={host='127.0.0.1',port=9999},react=REACT,logger=LOGGER}
	clis[i]:SetUserCB(cbmap)
end

local st=os.time()
local st1=st
local num=0
local cbfun
cbfun=function(cli,ch)
	if type(ch)~='table' then return end
	num=num+1
	if num%20000==0 then
		local et=os.time()
		print(ch.sn,os.time(),'rate',20000/(et-st),'/s','avg',num/(et-st1),'/s')
		st=et
	end
	cli:ACall(cbfun,0,'demo','zGet',{})
end
cbmap.cb_conn_ready=function(cli)
	print('connect success')
	cli:ACall(cbfun,0,'demo','zGet',{})
end
cbmap.cb_broken=function(cli)
	print('connect broken')
end
cbmap.cb_noti=function(cli,ch,bd)
	print('recv noti',ch,bd)
end

cbmap.cb_msg=function(cli,ch,bd)

end




while(1) do
	REACT:Dispatch(1)
end